package com.mcp.converter.domain.rule.compatibility.datatype;

import com.mcp.converter.domain.checker.IncompatibilityDetail;
import com.mcp.converter.shared.response.sql.SQLElement;
import com.mcp.converter.domain.rule.compatibility.AbstractDataTypeRule;

/**
 * BFILE数据类型兼容性规则检查器
 * OceanBase不支持BFILE数据类型
 * @author zengxiong
 */
public class BFileDataTypeRule extends AbstractDataTypeRule {
    
    private static final String RULE_ID = "DT001";
    private static final String RULE_NAME = "BFILE类型检查";
    private static final String RULE_DESCRIPTION = "检查是否使用了OceanBase不支持的BFILE数据类型";
    
    public BFileDataTypeRule() {
        super(RULE_ID, RULE_NAME, RULE_DESCRIPTION);
        setIncompatibilityDetail(
            "BFILE数据类型在OceanBase中不可用",
            "无法存储大文件对象",
            "建议转换为BLOB类型并配合外部存储",
            IncompatibilityDetail.Severity.HIGH);
    }

    @Override
    public boolean matches(Object target) {
        if (target instanceof SQLElement) {
            SQLElement element = (SQLElement) target;
            if (isDataTypeElement(element)) {
                return "BFILE".equalsIgnoreCase(element.getValue());
            }
        }
        return false;
    }
}